package bd.project;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Administrador extends JFrame implements ActionListener {
	
	private JButton btCreateProcess, btCreatePlaces, btCreateTable, btExit, btCreateUser;
	private JPanel mainPanel;
	private JLabel lbTitle, backG;
	
	public Administrador() {
		super("Administrador");
		inicializarComponentes();
		acomodarComponentes();
		conectarEscuchas();
		
		Container contenedor = getContentPane();
        contenedor.setLayout(null);
		
		setSize(500,500);
        setVisible(true);
        setResizable(false);
        
        contenedor.add(mainPanel);
	}
	
	public void actionPerformed( ActionEvent evento ) {
		if (evento.getSource()== btExit){
            this.dispose();
        }
        if (evento.getSource() == btCreateUser){
		//	CrearUsuario application = new CrearUsuario();
                        
                        
		}
	}
	
	public void inicializarComponentes() {
		ImageIcon image = new ImageIcon("alcaldia2.png");
		backG = new JLabel();
        backG.setIcon(image);
        
		btCreateProcess = new JButton("Crear Eleccion");
		btCreatePlaces = new JButton("Crear Puestos");
		btCreateTable = new JButton("Crear Mesas");
		btCreateUser = new JButton("Crear Usuario");
		btExit = new JButton("Salir");
		
		lbTitle = new JLabel("Alcaldia Municipal",SwingConstants.CENTER);
		Font auxFont = lbTitle.getFont(); 
		lbTitle.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 20));
		lbTitle.setBackground(Color.lightGray);
		lbTitle.setOpaque(true);
		
		mainPanel = new JPanel(null);
		mainPanel.setBackground(Color.WHITE);
		mainPanel.add(btCreateProcess);
		mainPanel.add(btCreateUser);
		//mainPanel.add(btCreatePlaces);
		//mainPanel.add(btCreateTable);
		mainPanel.add(btExit);
		mainPanel.add(lbTitle);
		mainPanel.add(backG);
	}
	
	public void acomodarComponentes() {
		btCreateProcess.setBounds(30, 130, 140, 30);
		btCreateUser.setBounds(30, 180, 140, 30);
		//btCreatePlaces.setBounds(30, 180, 140, 30);
		//btCreateTable.setBounds(30, 230, 140, 30);
		btExit.setBounds(30, 360, 140, 30);
		lbTitle.setBounds(0, 10, 500, 30);
		mainPanel.setBounds(0,0, 500, 500);
		backG.setBounds(0,0,500,500);
	}
	
	public void conectarEscuchas() {
		btCreateProcess.addActionListener(this);
		//btCreatePlaces.addActionListener(this);
		//btCreateTable.addActionListener(this);
		btCreateUser.addActionListener(this);
		btExit.addActionListener(this);
	}
	
	/*public static void main (String args[]) {
		Administrador application = new Administrador();
		application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
	}*/
	
}
	
